<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Overtrue\EasySms\EasySms;

class SmsController extends Controller
{
    private $_config = [
        // HTTP 请求的超时时间（秒）
        'timeout' => 5.0,
    
        // 默认发送配置
        'default' => [
            // 网关调用策略，默认：顺序调用
            'strategy' => \Overtrue\EasySms\Strategies\OrderStrategy::class,
    
            // 默认可用的发送网关
            'gateways' => [
                'aliyun', 'alidayu','yunpian', 
            ],
        ],
        // 可用的网关配置
        'gateways' => [
            'errorlog' => [
                'file' => '/tmp/easy-sms.log',
            ],
            'yunpian' => [
                'api_key' => '824f0ff2f71cab52936axxxxxxxxxx',
            ],
            'aliyun' => [
                'access_key_id' => '',
                'access_key_secret' => '',
                'sign_name' => '',
            ],
            'alidayu' => [
                //...
            ],
        ],
    ];
    // demo
    public function testsms()
    {
        
        $easySms = new EasySms($this->_config);
        // 这里写短信模板
        $easySms->send(13188888888, [
            'content'  => '您的验证码为: 6379',
            'template' => 'SMS_001',  // 短信模板id
            'data' => [
                'code' => 6379
            ],
        ]);
    }   
}
